package com.safeneeds.sysmana.ser.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.safeneeds.sysmana.dto.DataStoreLog;
import com.safeneeds.sysmana.entity.SysLog;
import com.safeneeds.sysmana.entity.dao.ISysLogDao;
import com.safeneeds.sysmana.ser.ISysLogService;
import com.safeneeds.util.page.PageInfo;
import com.safeneeds.util.page.ser.IPageService;

/**
 * 日志管理服务类
 * @author gaof
 * @date 2016年12月21日
 */
@Service
@Transactional
public class SysLogService implements ISysLogService {

	@Resource(name="sysLogDao")
	private ISysLogDao sysLogDao;
	
	@Resource(name="pageService")
	private IPageService pageService;
	
	/**
	 * 获取日志分页数据
	 * @param pageInfo
	 * @return
	 */
	@Override
	public PageInfo listLogPage(PageInfo pageInfo, DataStoreLog dataStore) {
		
		pageInfo = sysLogDao.listLogPage(pageInfo, dataStore);
		pageInfo = pageService.getPageInfoList(pageInfo);
		
		return pageInfo;
	}

	/**
	 * 添加系统日志
	 * @param log
	 */
	@Override
	public boolean addLog(SysLog log) {
		
		log.setLogTime(new Date());
		sysLogDao.addLog(log);
		
		return true;
	}

}
